import { baseListInfo } from '../base/baseList'
import { pageInfo } from '../base/baseRequestPage'

export interface goodsInfo {
  id: string
  /**
   * 商品名称
   */
  name: string
  /**
   * 副标题
   */
  subtitle: string
  /**
   * 商品价格
   */
  price: number
  /**
   * 商品小图地址
   */
  imageUrl: string
  /**
   * 商品数量
   */
  goodsNum: number
  /**
   * 是否在售
   */
  onSale: boolean
  /**
   * 是否推荐到平台
   */
  recommend: boolean
  /**
   * 排序
   */
  sort: number
  /**
   * 结算方式 CASH 现金 INTEGRAL 积分
   */
  buyType: string
}
export interface goodsTable extends goodsInfo {
  /**
   * 商品规格
   */
  specName: string
  /**
   * 商品规格详情
   */
  specDetailName: string
  /**
   * 品牌id
   */
  brandName: string
  /**
   * 标签id
   */
  labelName: string
  /**
   * 商品图片/视频 地址
   */
  url: string
}
export interface goodsS extends pageInfo {
  /**
   * 商品规格id
   */
  specId: string
  /**
   * 商品规格详情id
   */
  specDetailId: string
  /**
   * 品牌id
   */
  brandId: string
  /**
   * 标签id
   */
  labelId: string
  /**
   * 类型id
   */
  typeId: string
  /**
   * 商品名称
   */
  name: string
  /**
   * 开始价格
   */
  startPrice: number | null
  /**
   * 结束价格
   */
  endPrice: number | null
  /**
   * 是否在售
   */
  onSale: boolean | null
}
export interface goodsEdit extends goodsInfo {
  /**
   * 商品规格id
   */
  specId: string
  /**
   * 商品规格详情id
   */
  specDetailId: string
  /**
   * 品牌id
   */
  brandId: string
  /**
   * 标签id
   */
  labelId: string
  /**
   * 类型id
   */
  typeId: string
  /**
   * 介绍
   */
  introduce: string
}
export class goodsClass {
  goodsTable = [] as goodsTable[]
  type = [] as baseListInfo[]
  spec = [] as baseListInfo[]
  brand = [] as baseListInfo[]
  labels = [] as baseListInfo[]
  files = {}
  typeIdSList = []
  props = {
    label: 'name',
    value: 'id',
    children: 'children',
    emitPath: false
  }
  openDialog = false
  goodsS: goodsS = {
    specId: '',
    specDetailId: '',
    brandId: '',
    labelId: '',
    typeId: '',
    name: '',
    startPrice: null,
    endPrice: null,
    onSale: null,
    page: 1,
    size: 10,
    total: 0
  }
  goodsEdit: goodsEdit = {
    specId: '',
    specDetailId: '',
    brandId: '',
    labelId: '',
    typeId: '',
    id: '',
    name: '',
    subtitle: '',
    price: 0,
    imageUrl: '',
    goodsNum: 0,
    onSale: false,
    recommend: false,
    sort: 0,
    buyType: '',
    introduce: ''
  }
  openLabel = false
  label = ''
  goodRules = {
    name: [
      {
        required: true,
        message: '名称不能为空',
        trigger: 'blur'
      }
    ],
    typeIdEList: [
      {
        required: true,
        message: '类型不能为空',
        trigger: 'change'
      }
    ],
    brandId: [
      {
        required: true,
        message: '品牌不能为空',
        trigger: 'change'
      }
    ],
    specId: [
      {
        required: true,
        message: '规格不能为空',
        trigger: 'change'
      }
    ],
    buyType: [
      {
        required: true,
        message: '结算方式不能为空',
        trigger: 'change'
      }
    ],
    price: [
      {
        required: true,
        message: '金额不能为空',
        trigger: 'change'
      }
    ],
    sort: [
      {
        required: true,
        message: '排序不能为空',
        trigger: 'change'
      }
    ],
    goodsNum: [
      {
        required: true,
        message: '商品数量不能为空',
        trigger: 'change'
      }
    ],
    imageUrl: [
      {
        required: true,
        message: '商品小图不能为空',
        trigger: 'change'
      }
    ]
  }
  buyTypeList = [
    {
      value: 'CASH',
      label: '现金'
    },
    {
      value: 'INTEGRAL',
      label: '积分'
    }
  ]
  onSale = [
    {
      value: true,
      label: '是'
    },
    {
      value: false,
      label: '否'
    }
  ]
}
